package com.hmall.api.client;

import com.hmall.api.config.DefaultFeignConfig;
import com.hmall.api.domain.dto.ItemDTO;
import com.hmall.api.domain.dto.OrderDetailDTO;
import com.hmall.api.fallback.ItemClientFallBackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;

//@FeignClient(value="item-service", path = "/items") //标识一个远程调用客户端；并指定服务提供者的名字（微服务名称）
@FeignClient(value = "item-service", configuration = DefaultFeignConfig.class
, fallbackFactory = ItemClientFallBackFactory.class) //标识一个远程调用客户端；并指定服务提供者的名字（微服务名称）
public interface ItemClient {

    //与要调用的微服务item-service里面接口一致
    @GetMapping("/items")
    public List<ItemDTO> queryItemByIds(@RequestParam("ids") Collection<Long> ids);

    @PutMapping("/items/stock/deduct")
    public void deductStock(@RequestBody List<OrderDetailDTO> items);
}
